<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title><s:text name="content.list.title"/></title>
	<%@ include file="/common/meta.jsp"%>
	<%@ include file="/common/common.jsp"%>
    <script type="text/javascript" src="${ctx}/js/My97DatePicker/WdatePicker.js"></script>
</head>
<body>
<div id="wrapper">
<div id="main_box">
	<div class="curmb">您现在的位置:<a href="${ctx}/main.action">首页</a><span>></span>站内内容查询</div>
	<div class="listtit" id="listtit"><p><span><strong>内容搜索列表><s:property value="content.category.catName"/></strong></span></p></div>
	 
<s:form action="content-site" id="action_form">
	<div class="searchbox">
		<table class="searchTable">
			<tbody id="searchTable">
				<tr>
				    <td class="text"><label for="search" class="labelKeywords">文章ID:</label></td>
				    <td class="input"><s:textfield name="content.contentId" cssClass="txtin150"/></td>
					<td class="text"><label for="search" class="labelKeywords">关键字:</label></td>
					<td class="input"><s:textfield name="content.keyword" cssClass="txtin150"/></td>
					<td class="text"><label for="search" class="labelKeywords">修改人:</label></td>
					<td class="input"><s:textfield name="content.updateLoginName" cssClass="txtin150"/></td>
		            <td rowspan="3"><input type="submit" value="查询" class="btnsearch" id="search_btn"/></td>
				</tr>
				<tr>
					<td class="text"><label for="search" class="labelKeywords">文章类型:</label></td>
				    <td class="input"><s:select list="contentTypes" name="content.docType" cssClass="selectClass"  listKey="key" listValue="value"  headerKey="" headerValue="---请选择---"/></td>
					<td class="text"><label for="qry_contentStatus">文章状态: </label></td>
					<td class="input"><s:select list="dicContentType" name="content.contentStatus" cssClass="selectClass" listKey="dictionaryKey" listValue="dictionaryValue" headerKey="" headerValue="---请选择---"/></td> 
					<td class="text"><label for="search" class="labelKeywords">起始时间:</label></td>
				    <td class="input"><input name="content.startTime"  class="Wdate w140" id="qry_startTime" readonly="true"  value="<s:property value="%{formatDate(content.startTime)}"/>"
							onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'qry_endTime\')||\'2030-10-01\'}',skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="text"/></td>
				</tr>
				<tr>
					<td class="text">自定义属性</td>
					<td  colspan="3">
						<input type="checkbox" name="content.top" id="is_top"/><label for="is_top">置顶</label>
						<input type="checkbox" name="content.orig" id="is_orig"/><label for="is_orig">原创</label>
						<input type="checkbox" name="content.trans" id="is_trans"/><label for="is_trans">转载</label>
						<input type="checkbox" name="content.newest" id="is_newest"/><label for="is_newest">最新 </label>
						<input type="checkbox" name="content.recom" id="is_recom"/><label for="is_recom">推荐 </label>
						<input type="checkbox" name="content.pick" id="is_pick"/><label for="is_pick">精选</label>
						<input type="checkbox" name="content.hotest" id="is_hotest"/><label for="is_hotest">热点</label>
					</td> 
					<td class="text"><label for="search" class="labelKeywords">终止时间:</label></td>
				    <td class="input"><input name="content.endTime"  class="Wdate w140" id="qry_endTime" readonly="true"  value="<s:property value="%{formatDate(content.endTime)}"/>"
							onFocus="WdatePicker({minDate:'#F{$dp.$D(\'qry_startTime\')}',skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="text"/></td>
				</tr>
			</tbody>
		</table>
		<div class="clear"></div>
	</div>
	<div class="listoperate">
		<span class="cssa"  id="top_new_btn_f" >
 
		</span>
		<span>
			<input type="button" value="反选" class="btnlist2" id="top_anti_btn"/>
			<input type="button" value="发布"  class="btnlist2" id="top_publish"/>	
			<input type="button" value="导入/导出"  class="btnlist2" id="top_publish" onclick="javascript:window.location='${ctx}/content/content-exp-imp.action'"/>		 
		</span>
	</div>

	<div class="listbox" id="listbox">
		<table class="listgrid" id="listbox">
			<tbody>
				<tr id="table_th">
					<th><input type="checkbox" name="all" id="all_check"/></th>			
					<th>序号</th>
					<th>文章标题&nbsp;&nbsp;<a id="contentTitle_up" ><img src="${ctx}/imgs/up.png"/></a> <a id="contentTitle_down"><img src="${ctx}/imgs/down.png"/></a></th>	
					<th>类型</th>
					<th>栏目&nbsp;&nbsp;<a id="category.catName_up" ><img src="${ctx}/imgs/up.png"/></a> <a id="category.catName_down"><img src="${ctx}/imgs/down.png"/></a></th>
					<th>创建人&nbsp;&nbsp;<a id="createLoginName_up"><img src="${ctx}/imgs/up.png"/></a> <a id="createLoginName_down"><img src="${ctx}/imgs/down.png"/></a></th>	
					<th>修改人&nbsp;&nbsp;<a id="updateLoginName_up"><img src="${ctx}/imgs/up.png"/></a> <a id="updateLoginName_down"><img src="${ctx}/imgs/down.png"/></a></th>
					<th>修改时间&nbsp;&nbsp;<a id="updateTime_up"><img src="${ctx}/imgs/up.png"/></a> <a id="updateTime_down"><img src="${ctx}/imgs/down.png"/></a></th>
					<th>发布人&nbsp;&nbsp;<a id="publishLoginName_up"><img src="${ctx}/imgs/up.png"/></a> <a id="publishLoginName_down"><img src="${ctx}/imgs/down.png"/></a></th>
					<th>文章状态&nbsp;&nbsp;<a id="contentStatus_up"><img src="${ctx}/imgs/up.png"/></a> <a id="contentStatus_down"><img src="${ctx}/imgs/down.png"/></a></th>		
					<th>点击量&nbsp;&nbsp;<a id="contentHits_up"><img src="${ctx}/imgs/up.png"/></a> <a id="contentHits_down"><img src="${ctx}/imgs/down.png"/></a></th>
					<th>是否置顶&nbsp;&nbsp;<a id="isTop_up"><img src="${ctx}/imgs/up.png"/></a> <a id="isTop_down"><img src="${ctx}/imgs/down.png"/></a></th>
					<th>操作</th>
				</tr>
				<s:set var="num" value="(page.pageNo-1)*page.pageSize"/> 
				<s:iterator value="page.result" status="s">  
					<tr > 
				    	<td ><input type="checkbox" alt="<s:property value="contentStatus"/>" value="<s:property value="contentId"/>"  
				    		<s:if test='isLocked' >title="文章已锁定"  disabled="disabled"</s:if><s:else> name="key" </s:else>
				    	></td> 
				    	<td ><s:property value="#s.count+#num"/></td> 
				    	<td align="left"><s:property value="contentTitle"/><font color='red'><s:property value="Properties"/></font></td> 
				    	<td ><s:text name="content.contextType.%{contextType}"/></td> 	
				    	<td ><s:property value="category.catName"/></td> 
				    	<td><s:property value="createLoginName"/></td>
				    	<td><s:property value="updateLoginName"/></td>
				    	<td><s:date name="updateTime"  format="yyyy-MM-dd HH:mm:ss"/></td>
				    	<td><s:property value="publishLoginName"/></td>
				    	<td><s:property value="%{getName(contentStatus,'CONTENT_STATUS')}"/></td>
				    	<td><s:property value="contentHits"/></td>
				    	<td> 
				    		<s:if test="isTop==1">是</s:if>
				    		<s:else>否</s:else>
				    	</td>
					    <td>
					    	<s:if test="isLocked">
					    		<s:if test="%{authLicence('3_3_6',category.categoryId)}">
						    		<a href="###" onclick="unlock('<s:property value="contentId"/>')">解锁</a>
						    	</s:if>
						    	<s:else>文章已经被锁定
						    	</s:else>
					    	</s:if>
					    	<s:else> 					    	 
					    	    <!-- 
					    	    	草稿： 		编辑	-1
					    	    	待审核：	审核	编辑	0	
					    	    	审核通过	发布	编辑	1
					    	    	审核不通过：	编辑	2
					    	    	已经发布	浏览	编辑	3	
					    	    	
					    	    	锁定（单独字段）：0  1  
					    	     -->
				    	 		<s:if test="contentStatus.equals(\"0\")">
				    	 			<s:if test="%{authLicence('3_3_4',category.categoryId)}">	
										<a href="#this" onclick="goAudit('<s:property value="contentId"/>','1','<s:property value="contextType"/>')">审核</a><tt>|</tt>
									</s:if>
				    	 		</s:if> 
								<s:if test="contentStatus.equals(\"1\")">
										<s:if test="%{authLicence('3_3_2',category.categoryId)}">	
											<a href="#this" onclick="goPublish('<s:property value="contentId"/>','3')">发布</a><tt>|</tt>
										</s:if> 
							    </s:if>	 		     
						    	<s:if test="contentStatus.equals(\"3\")">
										<s:if test="(\"LinkContent\").equals(contextType)">
											<a href="#this" onclick="window.open('<s:property value="linkUrl"/>')">浏览</a><tt>|</tt>
										</s:if>
										<s:else>
											<a href="#this" onclick="window.open('<s:property value="content.category.site.siteDomain"/>/<s:property value="publishUrl"/>')">浏览</a><tt>|</tt>
										</s:else>
								</s:if> 
						    	<s:if test="%{authLicence('3_3_3',category.categoryId)}">								
									<s:if test="contextType.equals(\"Content\")"><a href="#this" onclick="goEdit('content.contentId','<s:property value="contentId"/>')"><s:text name="edit"/></a></s:if>
									<s:if test="contextType.equals(\"VideoContent\")"><a href="#this" onclick="goVideoEdit('videoContent.contentId','<s:property value="contentId"/>')"><s:text name="edit"/></a></s:if>
									<s:if test="contextType.equals(\"FlashContent\")"><a href="#this" onclick="goFlashEdit('flashContent.contentId','<s:property value="contentId"/>')"><s:text name="edit"/></a></s:if>
									<s:if test="contextType.equals(\"LinkContent\")"><a href="#this" onclick="goLinkEdit('linkContent.contentId','<s:property value="contentId"/>')"><s:text name="edit"/></a></s:if>
									<s:if test="contextType.equals(\"PictureContent\")"><a href="#this" onclick="goPicEdit('pictureContent.contentId','<s:property value="contentId"/>')"><s:text name="edit"/></a></s:if>
									<s:if test="contextType.equals(\"SoftwareContent\")"><a href="#this" onclick="goSoftEdit('softwareContent.contentId','<s:property value="contentId"/>')"><s:text name="edit"/></a></s:if>
								</s:if> 
					    	</s:else>
					    </td>	 
					</tr>
				</s:iterator>
			</tbody>
		</table>
		
	</div>
	<div class="listoperateb h33"> 
		<div> 
		<input type="button" value="反选" class="btnlist2" id="bottom_anti_btn"/>
		<input type="button" value="发布"  class="btnlist2" id="bottom_publish"/>
		</div>
		<div class="pager fr w578"">
			<z:page numberNav="true" selectPageSize="true" input="true" id="ctrl" baseNav="false"/>
			<s:hidden name="content.orderBy" id="content_orderBy"/>
			<s:hidden name="content.orderFalg" id="content_orderFalg"/>
		</div>
	</div>
</div>
</s:form>

</div>

<div id='error' style="display: none"><s:actionmessage /></div>
</div>
 
 
 
 
<div id="lightbox_p" class="lightbox" >
	<div class="lighttit"><p><span><strong>发布文章</strong></span></p></div>
	<div class="lightmain">
		<div class="lightmaintit"><label id="returnInfo">正在发布文章....</label>
		</div>
		<div class="lightbtnbox">请稍等.....</div>
	</div>
</div>
</body>
</html>
<script type="text/javascript">
$$.layer("#top_new_btn_f","#addType","91");
$$.table_even(".listgrid");

$(function(){
	$("#content_orderBy").val('');
	$("#content_orderFalg").val('');
	$("#all_check").click(selAll);
	$("#top_anti_btn").click(antiSelect);
	$("#bottom_anti_btn").click(antiSelect); 
	$("#top_publish").click(publish);
	$("#bottom_publish").click(publish);	
	tableThSort();
	initShowType();
});
actionName = "content";	
function  tableThSort(){
	$("#table_th").find('a').each(function(i,item){
		$(item).bind({
			click:function(){
				tableThSubmit(item);
			}
		});
	}); 
}

function tableThSubmit(item){
	var obj = $(item).attr('id');
	var arr = obj.split('_');
	$("#content_orderBy").val(arr[0]);
	$("#content_orderFalg").val(arr[1]);
	$("#action_form").submit();
} 
$("#is_orig").click(function(){  
	if($(this).attr("checked")){
		if($("#is_trans").attr("checked"))
		   $("#is_trans").attr("checked",false);
	} 
});
$("#is_trans").click(function(){
	if($(this).attr("checked")){
		if($("#is_orig").attr("checked"))
		   $("#is_orig").attr("checked",false);
	} 
});
function initShowType(){
	if("<s:property value="content.top"/>" == '1') $("#is_top").attr('checked',true);
	if("<s:property value="content.orig"/>" == '1') $("#is_orig").attr('checked',true);
	if("<s:property value="content.trans"/>" == '1') $("#is_trans").attr('checked',true);
	if("<s:property value="content.newest"/>" == '1') $("#is_newest").attr('checked',true);
	if("<s:property value="content.recom"/>" == '1') $("#is_recom").attr('checked',true);
	if("<s:property value="content.pick"/>" == '1') $("#is_pick").attr('checked',true);
	if("<s:property value="content.hotest"/>" == '1') $("#is_hotest").attr('checked',true);
}

function goSoftEdit(param,id){
	document.location.href="softwarecontent-input.action?"+param+"="+id+"&orig=edit";
}
function goVideoEdit(param,id){
	document.location.href="videocontent-input.action?"+param+"="+id+"&orig=edit";
}
function goPicEdit(param,id){
	document.location.href="picturecontent-input.action?"+param+"="+id+"&orig=edit";
}
function goFlashEdit(param,id){
	document.location.href="flashcontent-input.action?"+param+"="+id+"&orig=edit";
}
function goLinkEdit(param,id){
	document.location.href="linkcontent-input.action?"+param+"="+id+"&orig=edit";
}
function goAudit(id,flag,type){
	type2= type.toLowerCase();
	var str = type.substring(0,1);
	var type3 = str.toLowerCase()+type.substring(1,type.length);
	document.location.href=type2+"-input.action?orig=input&contextType=0&"+type3+".category.categoryId=<s:property value="content.category.categoryId"/>&"+type3+".contentId="+id+"&cflag="+flag;
}
function unlock(id){
	document.location.href="content-unlock.action?orig=input&contextType=0&content.category.categoryId=<s:property value="content.category.categoryId"/>&content.contentId="+id;
}
function goPublish(id,flag){
	$$.shade("#bottom_publish","#lightclose_p,#lightsubmit_p","#lightbox_p","300");
	document.location.href="${ctx}/generate/publish-content.action?orig=input&contextType=0&content.category.categoryId=<s:property value="content.category.categoryId"/>&targets="+id+"&cflag="+flag+"&type=content";
}
function publish(){
	if($("input[name='key']:checked").size()==0){
		alert("请选择");
		return;
	}
	var id ='';
	var flag = false;
	<s:if test="!content.category.isAudit">
	$("input[name='key']:checked").each(function(){
		if($(this).attr("alt")!=1&&$(this).attr("alt")!=3&&$(this).attr("alt")!=0){
			flag=true;
		}
		id+=$(this).val()+",";
	});
	</s:if>
	<s:else>
	$("input[name='key']:checked").each(function(){
		if($(this).attr("alt")!=1&&$(this).attr("alt")!=3){
			flag=true;
		}
		id+=$(this).val()+",";
	});
	</s:else>
	
	if(flag){
		alert("文章无法发布！请选择可发布的文章");
		return false;
	}
	$$.shade("#bottom_publish","#lightclose_p,#lightsubmit_p","#lightbox_p","300");
	document.location.href = "${ctx}/generate/publish-content.action?orig=input&contextType=0&content.category.categoryId=<s:property value="content.category.categoryId"/>&targets="+id+"&cflag=3&type=content";
}
</script>
 